package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.controller.vo.RequestLoginVo;
import com.example.entity.User;
import com.example.mapper.UserMapper;
import com.example.service.IUserService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author yzy
 * @since 2025-08-04
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public User login(RequestLoginVo requestLoginVo) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_account", requestLoginVo.getLoginName());
        User user = baseMapper.selectOne(queryWrapper);
        if (user != null && !"".equals(user)) {
            if (requestLoginVo.getPwd().equals(user.getUserPwd())) {
                return user;
            }
            return null;
        }
        return null;
    }
}
